PRG 1.0 TXT

/*
	Aberration
*/

//-----------------------------------------------------------------------------
// [CONFIG]

include "..\program_include.ocf"

object Program
{
	textures	= array /*ProgramTexture*/ {
		{ "unColorMap", e_texture.DIFFUSE }
	}
	
	uniforms	= array /*string*/ {
		"transform", "unTransform.",
		"timer", 	 "unTime"
	}
}


//-----------------------------------------------------------------------------
// [VERTEX]

#version 330 core
#pragma optimize(on)

#define ATTR_POSITION	0
#define ATTR_TEXCOORD	2
#define ATTR_COLOR		1

layout(location = ATTR_POSITION)	in vec3 inPosition;
layout(location = ATTR_TEXCOORD)	in vec2 inTexcoord;


uniform struct Transform {
	mat4	Projection;
} unTransform;


out	TVertexData {
	vec2	vTexcoord;
} Output;


void main(void)
{
	gl_Position  	 = unTransform.Projection * vec4(inPosition, 1.0);
	Output.vTexcoord = inTexcoord;
}


//-----------------------------------------------------------------------------
// [FRAGMENT]

#version 330 core
#pragma optimize(on)

layout(location = 0, index = 0) out vec4	outColor;

uniform sampler2D	unColorMap;
uniform float		unTime;

in	TVertexData {
	vec2	vTexcoord;
} Input;


vec4 Filter(in vec2 texcoord)
{
	float		t = unTime*1.5;
	float		k = abs( sin(t) ) * 4.0;
	float		c = 1.0; //clamp( abs( sin( texcoord.y * 300.0 ) )+0.4, 0.4, 1.0 );
	vec2		size = vec2(1.0) / vec2( textureSize( unColorMap, 0 ) );
	
	vec3		ret =	vec3(
							texture( unColorMap, texcoord + size*k ).r,
							texture( unColorMap, texcoord ).g,
							texture( unColorMap, texcoord - size*k ).b
						);
	return vec4( ret * c, 1.0 );
}


void main()
{
	outColor = Filter( Input.vTexcoord );
}

// [END]
